import acl

ACL_SUCCESS = 0

def main():
    deviceId = 0
    aclConfigPath = "./acl.json"

    # acl资源初始化
    ret = acl.init(aclConfigPath)
    if ret != ACL_SUCCESS:
        print("acl.init failed ret = {}".format(ret))
        exit(1)
    print("acl.init run success.")

    ret = acl.rt.set_device(deviceId)
    if ret != ACL_SUCCESS:
        print("acl.rt.set_device failed ret = {}".format(ret))
        exit(1)
    print("acl.rt.set_device run success.")

    context, ret = acl.rt.create_context(deviceId)
    if ret != ACL_SUCCESS:
        print("acl.rt.create_context failed ret = {}".format(ret))
        exit(1)
    print("acl.rt.create_context run success.")


    # 释放acl资源
    ret = acl.rt.destroy_context(context)
    if ret != ACL_SUCCESS:
        print("acl.rt.destroy_context ret = {}".format(ret))
        exit(1)
    print("acl.rt.destroy_context run success.")

    ret = acl.rt.reset_device(deviceId)
    if ret != ACL_SUCCESS:
        print("acl.rt.reset_device ret = {}".format(ret))
        exit(1)
    print("acl.rt.reset_device run success.")

    ret = acl.finalize()
    if ret != ACL_SUCCESS:
        print("acl.finalize failed ret = {}".format(ret))
        exit(1)
    print("acl.finalize run success.")

if __name__ == '__main__':
    main()